﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Prob_Distributions_ClassLibrary
{
    class DistribucionUniforme : IDistribucion
    {        
        private RandomNumber rnd;
        private double lInferior;
        private double lSuperior;
        private double menor;
        private double mayor;
        public DistribucionUniforme(RandomNumber rnd,double lInferior,double lSuperior)
        {            
            this.rnd = rnd;
            this.lInferior = lInferior;
            this.lSuperior = lSuperior;
        }
        public List<double> getNRandoms(int cant)
        {
            List<double> lstRandoms = rnd.getNRandoms(cant);
            if (lstRandoms.Count > 0)
            {
                menor = lstRandoms[0];
                mayor = 0;
            }
            for (int i = 0; i < lstRandoms.Count; i++)
            {
                lstRandoms[i] = lInferior + lstRandoms[i] * (lSuperior - lInferior);
                if (lstRandoms[i] > mayor)
                    mayor = lstRandoms[i];
                if (lstRandoms[i] < menor)
                    menor = lstRandoms[i];
            }
            return lstRandoms;

        }
        public decimal getMayor() 
        {
            return (decimal) mayor;
        }
        public decimal getMenor()
        {
            return (decimal)menor;
        }
        public decimal getIntervalo(int intervalos)
        {
            return (decimal) (lSuperior-lInferior) / intervalos;
        }
        public double getLimiteSuperior()
        {
            return lSuperior;
        }
        public double getLimiteInferior()
        {
            return lInferior;
        }
    }
}
